﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace proLearningEnglish
{
    public partial class frmAddRelation : Form
    {
        private DataManager objDataManager;
        private string senseType;
        public frmAddRelation(DataManager objDM, string type)
        {
            InitializeComponent();
            this.objDataManager = objDM;
            senseType = type;
            loadWord();
        }

        private void loadWord()
        {
            cmbWord.Nodes.Clear();
            ComboTreeNode rootNode = new ComboTreeNode("Từ tiếng Anh");
            cmbWord.Nodes.Add(rootNode);
            List<Word> lst = objDataManager.getIsARootWordNodes();
            for (int i = 0; i < lst.Count; i++)
            {
                addNode(rootNode, lst[i]);
            }
            cmbWord.ExpandAll();
        }

        private void addNode(ComboTreeNode node, Word objWord)
        {
            ComboTreeNode nodeTmp = node.Nodes.Add(objWord.getID(), objWord.getLabel());
            nodeTmp.Tag = objWord;
            List<Word> lst = objDataManager.getIsAChildWordNodes(objWord);
            for (int i = 0; i < lst.Count; i++)
            {
                addNode(nodeTmp, lst[i]);
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
